package com.bingo.generate.comm.dto;

import lombok.Data;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

/**
 * ClassName
 * Description
 * Create by lc
 * Date 2021/11/22 9:50
 * excel的dto
 */
@Data
public class ExcelDto<T> {

    //  excel的输出路径
    private Path excelPath;

    //  列名
    private String[] excelTitle ;

    //  标签页标题\
    private String sheetTitle;

    private List<List> list;

    //  转换为每一行数据的方法
    private Function<T,Object[]> toArr;

    public void setListArr(String[][] arr) {
        list=new ArrayList();
        for (String[] row : arr) {
            List rowList=new ArrayList();
            for (String s : row) {
                rowList.add(s);
            }
            list.add(rowList);
        }
    }

    public void setExcelTitleList(List<String> list) {
        String[] arr=new String[list.size()];
        arr = list.toArray(arr);
        excelTitle=arr;
    }
}
